﻿using System.Text;

namespace System;

public static partial class Extends
{

    public static bool Eqauls(this byte[] a, byte[] b)
    {
        if (a.Length != b.Length) return false;
        return !a.Where((t, i) => t != b[i]).Any();
    }


    /// <summary>
    /// 扩展方法获取Message和StackTrace
    /// </summary>
    /// <param name="exception"></param>
    /// <returns></returns>
    public static string ErrorMessage(this Exception exception)
    {
        Console.WriteLine("==================================");
        var expSb = new StringBuilder();
        expSb.Append(exception.Message);
        expSb.Append("\r\n");
        expSb.Append(exception.StackTrace);
        if (exception.InnerException == null) return expSb.ToString();
        expSb.Append("\r\n");
        expSb.Append(exception.InnerException.Message);
        expSb.Append("\r\n");
        expSb.Append(exception.InnerException.StackTrace);
        return expSb.ToString();
    }

}